[HOLD] chore(otel): Migrate from v1 to v2 #1844
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed
This PR migrates the
@temporalio/interceptors-opentelemetrypackage from OpenTelemetry (OTel) v1.x to v2.x.Core Changes:
@opentelemetry/*dependencies to compatible v2 versions.Why?
Migration to OpenTelemetry V2
This PR uses
BasicTracerProviderand avoids usingNodeTracerProvider: #1741The Reasoning:(LLM)
windowandperformance). It explicitly removes Node.js globals likeprocessand restricts access to native modules.NodeTracerProviderattempts to loadasync_hooks(a native Node module) to manage context. Since the sandbox blocks native modules, usingNodeTracerProviderwill cause the workflow to crash or behave non-deterministically. We must useBasicTracerProviderwhich is platform-agnostic.BasicTracerProviderimplicitly registered environment-based propagators. In OTel V2, this side effect was removed. As a result, trace context propagation was failing (generating fragmented traces forStartWorkflow->RunWorkflow->RunActivity).otel.propagation.setGlobalPropagator(new W3CTraceContextPropagator())to manually restore the behavior required for the Sandbox to extract/inject headers correctly.Checklist
Closes: [Feature Request] Add support for opentelemetry v2 #1658
How was this tested:
pnpm test